﻿using Kinlo.Model.Enum;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace KINLO.UI.Main.Converter
{
    public class TeamEnumToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && !string.IsNullOrWhiteSpace(value.ToString()))
            {
                TeamType team = (TeamType)Enum.ToObject(typeof(TeamType), int.Parse(value.ToString()));
                return team;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null && !string.IsNullOrWhiteSpace(value.ToString()))
            {
                TeamType enumValue = (TeamType)Enum.Parse(typeof(TeamType), value.ToString());
          
                return (int)enumValue;
            }
            return null;
        }
    }
}
